package com.hele.sts.action.admin;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hele.sts.dao.QyjnmlbDao;
import com.hele.sts.exception.BusinessException;
import com.hele.sts.webwork.PageAction;
import com.opensymphony.xwork2.ActionContext;

public class ImageListAction extends PageAction {

	String action;
	String errorInfo;
	
	String nbxh;
	String jnmlbh;
	String inmlbh;
	String msg;
	List imageList;

	static Logger logger = LoggerFactory.getLogger(DocumentListAction.class);

	public String execute() throws Exception {
		ActionContext ctx = ActionContext.getContext();
		Map session = ctx.getSession();
		String loginName = (String) session.get("AdminUser.loginName");
		if ((loginName == null) || (loginName.length() < 1)) {
			return "error";
		}
		if ((this.action == null) || ("list".equalsIgnoreCase(this.action))) {
			return super.execute();
		}
		if("resetSmbz".equals(this.action)){
			if(nbxh==null||jnmlbh==null||inmlbh==null){
				msg = "参数缺失";
			}else{
				try {
					QyjnmlbDao.resetSmbz(nbxh,jnmlbh,inmlbh);
					msg = "重置成功";
				}catch(BusinessException e){
					msg = e.getMessage();
				}
			}
			return "ajax";
		}
		return "none";
	}

	@Override
	public String getHref() {
		String href = "";
		if ((this.nbxh != null) && (this.nbxh.length() > 0)) {
			href = href + "&nbxh=" + this.nbxh;
		}
		return href;
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		return QyjnmlbDao.count(nbxh);
	}

	@Override
	public String list() {
		imageList = QyjnmlbDao.load(nbxh, getPageNo(),getPageSize());
		return "list";
	}

	public String getErrorInfo() {
		return this.errorInfo;
	}

	public void setErrorInfo(String errorInfo) {
		this.errorInfo = errorInfo;
	}

	public String getAction() {
		return this.action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	/**
	 * @return the nbxh
	 */
	public String getNbxh() {
		return nbxh;
	}

	/**
	 * @param nbxh the nbxh to set
	 */
	public void setNbxh(String nbxh) {
		this.nbxh = nbxh;
	}

	/**
	 * @return the imageList
	 */
	public List getImageList() {
		return imageList;
	}

	/**
	 * @param imageList the imageList to set
	 */
	public void setImageList(List imageList) {
		this.imageList = imageList;
	}

	/**
	 * @return the jnmlbh
	 */
	public String getJnmlbh() {
		return jnmlbh;
	}

	/**
	 * @param jnmlbh the jnmlbh to set
	 */
	public void setJnmlbh(String jnmlbh) {
		this.jnmlbh = jnmlbh;
	}

	/**
	 * @return the inmlbh
	 */
	public String getInmlbh() {
		return inmlbh;
	}

	/**
	 * @param inmlbh the inmlbh to set
	 */
	public void setInmlbh(String inmlbh) {
		this.inmlbh = inmlbh;
	}

	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

}
